home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Languages / MPW Oberon 2.1168 / OInterfaces / WorldScript.mod < prev   
Encoding:
Text File  |  1995-08-10  |  9.7 KB  |  347 lines  |  [TEXT/MPS ]

  1. (*
  2.      File:        WorldScript.mod
  3.  
  4.      Contains:    WorldScript I Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.0 in “MPW Latest” on ETO #17
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs.applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. *)
  19.  
  20. (*$TAGS-*)
  21. (*$CALLING PASCAL*)
  22. MODULE WorldScript;
  23.  
  24. IMPORT SYSTEM, Types, QuickdrawText;
  25.  
  26. (* $PUSH*)
  27. (* $ALIGN MAC68K*)
  28. (* $LibExport+*)
  29.  
  30. CONST
  31.     kVariableLengthArray*        = 1;
  32.  
  33.     
  34. TYPE
  35.     WSIOffset* = Types.UInt16;
  36.  
  37.     WSIByteCount* = Types.UInt8;
  38.  
  39.     WSIByteIndex* = Types.UInt8;
  40.  
  41. (* offset from start of sub-table to row in state table *)
  42.     WSIStateOffset* = Types.UInt16;
  43.  
  44.     WSITableOffset* = Types.UInt32;
  45.  
  46.     WSISubtableOffset* = Types.UInt16;
  47.  
  48.     WSIGlyphcode* = Types.UInt16;
  49.  
  50.     WSITableIdentifiers* = Types.UInt32;
  51.  
  52.  
  53. CONST
  54.     kScriptSettingsTag*            = LONG("info");
  55.     kMetamorphosisTag*            = LONG("mort");
  56.     kGlyphExpansionTag*            = LONG("g2g#");
  57.     kPropertiesTag*                = LONG("prop");
  58.     kJustificationTag*            = LONG("kash");
  59.     kCharToGlyphTag*                = LONG("cmap");
  60.     kGlyphToCharTag*                = LONG("pamc");
  61.     kFindScriptRunTag*            = LONG("fstb");
  62.  
  63. (****             L O O K U P    T A B L E    T Y P E S        ****)
  64.     WSILookupSimpleArray*        = 0;                            (* a simple array indexed by glyph code *)
  65.     WSILookupSegmentSingle*        = 2;                            (* segment mapping to single value *)
  66.     WSILookupSegmentArray*        = 4;                            (* segment mapping to lookup array *)
  67.     WSILookupSingleTable*        = 6;                            (* sorted list of glyph, value pairs *)
  68.     WSILookupTrimmedArray*        = 8;                            (* a simple trimmed array indexed by glyph code *)
  69.  
  70.     
  71. TYPE
  72.     WSILookupTableFormat* = INTEGER;
  73.  
  74.     WSILookupValue* = INTEGER;
  75.  
  76. (* An offset from the beginning of the lookup table *)
  77.     WSILookupOffset* = INTEGER;
  78.  
  79. (*    FORMAT SPECIFIC DEFINITIONS *)
  80. (* The format specific part of the subtable header *)
  81.     WSILookupFormatSpecificHeader* = RECORD
  82.         (*ΔΔCASE INTEGER OF
  83.         0: (
  84.             lookupArray*:                WSILookupArrayHeader;
  85.            );
  86.         1: (
  87.             trimmedArray*:                WSILookupTrimmedArrayHeader;
  88.            );ΔΔ*)
  89.     END;
  90.  
  91. (*
  92.         lookupSimpleArray*:
  93.         
  94.         This is a simple array which maps all glyphs in the font
  95.         to lookup values.
  96.     *)
  97.     WSILookupArrayHeader* = RECORD(WSILookupFormatSpecificHeader)
  98.         lookupValues*:            ARRAY 1 (*ΔΔ[0..0]ΔΔ*) OF WSILookupValue;            (* The array of values indexed by glyph code *)
  99.     END;
  100.  
  101. (*
  102.         lookupTrimmedArray*:
  103.         
  104.         This is a single trimmed array which maps a single range
  105.         of glyhs in the font to lookup values.
  106.     *)
  107.     WSILookupTrimmedArrayHeader* = RECORD(WSILookupFormatSpecificHeader)
  108.         firstGlyph*:                WSIGlyphcode;
  109.         limitGlyph*:                WSIGlyphcode;
  110.         valueArray*:                ARRAY 1 (*ΔΔ[0..0]ΔΔ*) OF WSILookupValue;
  111.     END;
  112.  
  113. (* The overall subtable header *)
  114.     WSILookupTableHeader* = RECORD
  115.         format*:                    WSILookupTableFormat;                    (* table format *)
  116.         fsHeader*:                WSILookupFormatSpecificHeader;            (* format specific header *)
  117.     END;
  118.  
  119. (****        G L Y P H    E X P A N S I O N    ****)
  120.  
  121. CONST
  122. (* fixed 1.0 *)
  123.     kCurrentGlyphExpansionVersion* = $00010000;
  124.  
  125.     
  126. TYPE
  127.     GlyphExpansionFormats* = INTEGER;
  128.  
  129.  
  130. CONST
  131.     GlyphExpansionLookupFormat*    = 1;
  132.     GlyphExpansionContextualFormat* = 2;
  133.  
  134.  
  135. TYPE
  136.     ExpandedGlyphCluster* = (*ΔΔPACKEDΔΔ*) RECORD
  137.         numGlyphs*:                WSIByteCount;
  138.         bestGlyph*:                WSIByteIndex;
  139.         glyphs*:                    ARRAY 1 (*ΔΔ[0..0]ΔΔ*) OF WSIGlyphcode;
  140.     END;
  141.  
  142.     ExpandedGlyphOffset* = RECORD
  143.         glyph*:                    WSIGlyphcode;
  144.         offset*:                    WSIOffset;                                (* offset to ExpandedGlyphCluster *)
  145.     END;
  146.  
  147.     GlyphExpansionStateTable* = RECORD
  148.         stateTableOffset*:        WSISubtableOffset;
  149.         classTableOffset*:        WSISubtableOffset;
  150.         actionTableOffset*:        WSISubtableOffset;                        (* state, class and actions tables follow here... *)
  151.     END;
  152.  
  153.     GlyphExpansionTable* = RECORD
  154.         version*:                Types.Fixed;
  155.         format*:                    INTEGER;
  156.         expansionNumer*:            INTEGER;
  157.         expansionDenom*:            INTEGER;                                (* num/denom ratio for expansion <2> *)
  158.         (*ΔΔCASE INTEGER OF
  159.         0: (
  160.             stateTable*:                    GlyphExpansionStateTable;
  161.            );
  162.         1: (
  163.             lookup*:                        WSILookupTableHeader;                (* expanded glyph clusters follow here... *)
  164.            );ΔΔ*)
  165.     END;
  166.  
  167. (* Glyph-to-Character constants and types  *)
  168.  
  169. CONST
  170.     kCurrentGlyphToCharVersion*    = $00010100;
  171.  
  172.     
  173. TYPE
  174.     GlyphToCharLookupFormats* = INTEGER;
  175.  
  176.  
  177. CONST
  178.     kGlyphToCharLookup8Format*    = 1;
  179.     kGlyphToCharLookup16Format*    = 2;
  180.     kGlyphToCharLookup32Format*    = 3;
  181.  
  182.     
  183. TYPE
  184.     GlyphToCharFontIndex* = Types.UInt8;
  185.  
  186.     QDGlyphcode* = Types.UInt8;
  187.  
  188.     GlyphToCharActionTable* = RECORD
  189.         fontNameOffset*:            WSISubtableOffset;                        (* offset relative to this table *)
  190.         actions*:                WSILookupTableHeader;                    (* only support lookupSimpleArray format for now *)
  191.     END;
  192.  
  193.     GlyphToCharActionHeader* = RECORD
  194.         numTables*:                INTEGER;                                (* 0..n *)
  195.         offsets*:                ARRAY 1 (*ΔΔ[0..0]ΔΔ*) OF WSISubtableOffset;        (* offsets from start of action table header *)
  196.     END;
  197.  
  198.     GlyphToCharHeader* = RECORD
  199.         version*:                Types.Fixed;
  200.         actionOffset*:            WSISubtableOffset;                        (* offset to GlyphToCharActionHeader *)
  201.         format*:                    INTEGER;                                (* size of font mask *)
  202.         mappingTable*:            WSILookupTableHeader;
  203.     END;
  204.  
  205. (* JUSTIFICATION TYPES
  206.     WorldScript supports justification of text using insertion. The justification
  207.     table specifies a insertion string to insert between 2 specified glyphs.
  208.     Each combination of inter-glyph boundary can be assigned a justification priority,
  209.     the higher the priority the more justification strings inserted at that position.
  210.     
  211.     The priorities for each inter-glyph boundary are specified by the justification table's
  212.     state table.
  213.     
  214.     Special handling is done for scripts which use spaces to justify, because the width of 
  215.     a space varies depending on the setting of SpaceExtra. This is why the number of spaces
  216.     per inserting string is specified in the justification table.
  217.  
  218. *)
  219.  
  220. CONST
  221. (* 1.0 not supported *)
  222.     kCurrentJustificationVersion* = $0200;
  223.  
  224.     kJustificationStateTableFormat* = 1;
  225.  
  226. (* WSI's internal limitation <12> *)
  227.     kMaxJustificationStringLength* = 13;
  228.  
  229.     
  230. TYPE
  231.     WSIJustificationPriority* = Types.UInt8;
  232.  
  233.  
  234. CONST
  235.     WSIJustificationSetMarkMask*    = $80;
  236.  
  237.  
  238. TYPE
  239.     WSIJustificationStateEntry* = (*ΔΔPACKEDΔΔ*) RECORD
  240.         markPriority*:            WSIJustificationPriority;                (* non-zero priorities means insertion *)
  241.         priority*:                WSIJustificationPriority;
  242.         newState*:                WSIStateOffset;
  243.     END;
  244.  
  245.     WSIJustificationClasses* = INTEGER;
  246.  
  247.  
  248. CONST
  249.     wsiJustEndOfLineClass*        = 0;
  250.     wsiJustEndOfRunClass*        = 1;
  251.     wsiJustDeletedGlyphClass*    = 2;
  252.     wsiJustUserDefinedClass*        = 3;
  253.  
  254.     
  255. TYPE
  256.     WSIJustificationStates* = INTEGER;
  257.  
  258.  
  259. CONST
  260.     wsiStartOfLineState*            = 0;                            (* pre-defined states *)
  261.     wsiStartOfRunState*            = 1;
  262.     wsiUserDefinedState*            = 2;
  263.  
  264. (* pre-multiplied: class# * sizeof(WSIJustificationStateEntry) *)
  265.     
  266. TYPE
  267.     WSIJustificationClassOffset* = Types.UInt8;
  268.  
  269.     WSIJustificationStateTable* = RECORD
  270.         maxPriorities*:            INTEGER;
  271.         rowWidth*:                INTEGER;                                (* width of a state table row in bytes *)
  272.         classTableOffset*:        INTEGER;
  273.         stateTableOffset*:        INTEGER;
  274.     END;
  275.  
  276.     WSIJustificationHeader* = RECORD
  277.         version*:                INTEGER;
  278.         format*:                    INTEGER;
  279.         scaling*:                Types.Point;                                    (* numer/denom scaling of priority weights <7> *)
  280.         spacesPerInsertion*:        INTEGER;                                (* # of $20 chars in justification insertion string <12> *)
  281.         justStringOffset*:        INTEGER;                                (* offset to justification string *)
  282.         stateTable*:                WSIJustificationStateTable;                (* long-aligned boundary aligned w/ spacesPerInsertion field - justification string follows *)
  283.     END;
  284.  
  285. (* Line Layout's Property table version <11> *)
  286.  
  287. CONST
  288. (* v1.0 *)
  289.     currentPropsTableVersion*    = $00010000;
  290.  
  291. (* ??? is this right *)
  292.     kCharToGlyphCurrentVersion*    = 0100;
  293.  
  294. (* pass as priorityWeight to JustifyWSILayout to use script's current just setting *)
  295.     kScriptsDefaultJustWeight*    = -1;
  296.  
  297.  
  298. TYPE
  299.     WSIGlyphInfoRec* = RECORD
  300.         qdChar*:                    Types.SInt8; (* UInt8 *)
  301.         rightToLeft*:            Types.SInt8;                                    (* !0 means rightToLeft, 0 means leftToRight *)
  302.         fontID*:                    INTEGER;
  303.         originalOffset*:            INTEGER;                                (* or negative original offset if not in original text input *)
  304.         unused*:                    INTEGER;                                (* long-align *)
  305.     END;
  306.  
  307.     WSIGlyphInfoRecPtr* = POINTER TO WSIGlyphInfoRec;
  308.     WSIGlyphInfoHandle* = HANDLE TO WSIGlyphInfoRec (*ΔΔPOINTER TO WSIGlyphInfoRecPtrΔΔ*);
  309.  
  310.     WSILayoutHandle* = Types.Handle;
  311.  
  312.  
  313. PROCEDURE NewWSILayout*(layoutH: WSILayoutHandle; text: Types.Ptr; txLength: INTEGER; lineDirection: INTEGER; flags: LONGINT; VAR err: Types.OSErr): WSILayoutHandle;
  314.     (*$IF NOT GENERATINGCFM*)
  315.     INLINE PASCAL $2F3C, $8414, $0040, $A8B5;
  316.     (*$END*)
  317. PROCEDURE JustifyWSILayout*(layoutH: WSILayoutHandle; slop: Types.Fixed; priorityWeight: INTEGER; styleRunPosition: QuickdrawText.JustStyleCode; numer: Types.Point; denom: Types.Point; VAR err: Types.OSErr): WSILayoutHandle;
  318.     (*$IF NOT GENERATINGCFM*)
  319.     INLINE PASCAL $2F3C, $8418, $0042, $A8B5;
  320.     (*$END*)
  321. PROCEDURE MeasureWSILayout*(layoutH: WSILayoutHandle; numer: Types.Point; denom: Types.Point): Types.Fixed;
  322.     (*$IF NOT GENERATINGCFM*)
  323.     INLINE PASCAL $2F3C, $840C, $0044, $A8B5;
  324.     (*$END*)
  325. PROCEDURE DrawWSILayout*(layoutH: WSILayoutHandle; numer: Types.Point; denom: Types.Point);
  326.     (*$IF NOT GENERATINGCFM*)
  327.     INLINE PASCAL $2F3C, $800C, $0046, $A8B5;
  328.     (*$END*)
  329. (* "low-level" routines *)
  330. PROCEDURE GetWSILayoutParts*(layoutH: WSILayoutHandle; destH: WSIGlyphInfoHandle; VAR numGlyphs: INTEGER; VAR err: Types.OSErr): WSIGlyphInfoHandle;
  331.     (*$IF NOT GENERATINGCFM*)
  332.     INLINE PASCAL $2F3C, $8410, $0048, $A8B5;
  333.     (*$END*)
  334. PROCEDURE DrawWSIGlyphs*(length: INTEGER; qdCodes: Types.Ptr; numer: Types.Point; denom: Types.Point);
  335.     (*$IF NOT GENERATINGCFM*)
  336.     INLINE PASCAL $2F3C, $800E, $004A, $A8B5;
  337.     (*$END*)
  338. PROCEDURE xMeasureWSIGlyphs*(VAR qdCodes: Types.Ptr; length: INTEGER; numer: Types.Point; denom: Types.Point): Types.Fixed;
  339.     (*$IF NOT GENERATINGCFM*)
  340.     INLINE PASCAL $2F3C, $840E, $004C, $A8B5;
  341.     (*$END*)
  342.  
  343. (* $ALIGN RESET*)
  344. (* $POP*)
  345.  
  346.  END WorldScript.
  347.